var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIConfig"),
    s = t("UIManager"),
    c = t("GameEm"),
    p = t("TimeViewNode2"),
    l = cc._decorator,
    d = l.ccclass,
    u = l.property,
    h =
        (l.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.coin = null;
                e.btnNode = null;
                e.costLab = null;
                e.timeShopItem = null;
                e.kind = -1;
                e.id = -1;
                e.canClick = !1;
                e.rewardData = null;
                return e;
            }
            e.prototype.updateView = function (t) {
                this.updateRewardKind(t);
                this.openGuild();
            };
            e.prototype.openGuild = function () {
                if (
                    GuildCache.isOverOnceGuid(GuildCache.oncecheckId[2][0]) &&
                    !GuildCache.isOverOnceGuid(GuildCache.oncecheckId[2][7])
                ) {
                    GuildCache.checkKey = GuildCache.oncecheckId[2][7];
                    GuildCache.overOnceGuid(GuildCache.oncecheckId[2][7]);
                    GuildCache.openGuildView();
                }
            };
            e.prototype.checkAdView = function (t) {
                if (this.timeShopItem) {
                    var e = GameDataValue.getShopTimeCount(1, this.id),
                        o = Date.now() - e,
                        a = t.time_cd || 0;
                    if (o >= (a *= 1e3)) {
                        this.timeShopItem.node.active = !1;
                        this.btnNode.active = !0;
                        this.setBtnRender(!0);
                    } else {
                        this.timeShopItem.node.active = !0;
                        this.btnNode.active = !1;
                        this.timeShopItem.checkView(e, a, this.moveTimeCall.bind(this));
                        this.setBtnRender(!1);
                    }
                }
            };
            e.prototype.setBtnRender = function () {};
            e.prototype.moveTimeCall = function (t) {
                if ("1" == t) {
                    this.btnNode.active = !0;
                    this.timeShopItem.node.active = !1;
                } else {
                    this.timeShopItem.node.active = !0;
                    this.btnNode.active = !1;
                }
            };
            e.prototype.updateRewardKind = function (t) {
                this.rewardData = t;
                switch (t.cost_item) {
                    case 10:
                        this.setBtnCoin(1);
                        this.costLab.string = "免费";
                        this.canClick = !1;
                        this.checkAdView(t);
                        break;
                    case 6:
                        this.checkReward(t, 2);
                        break;
                    case 7:
                        this.checkReward(t, 3);
                }
            };
            e.prototype.checkReward = function (t, e) {
                var o = GameDataValue.getShopKey(t.cost_item),
                    a = t.cost_num || 0;
                if (o >= a && a > 0) {
                    this.costLab.string = o + "/" + a;
                    this.setBtnCoin(e);
                    this.setBtnRender(!0);
                } else {
                    var i = t.diamond_num || 0;
                    this.costLab.string = "" + i;
                    this.setBtnCoin(4);
                    GameDataValue.getPropCount(c.PropKind.zhuanshi) >= i
                        ? this.setBtnRender(!0)
                        : this.setBtnRender(!1);
                }
                this.canClick = !0;
            };
            e.prototype.setBtnCoin = function (t) {
                SpriteView.setBtnCoin(t, this.coin);
            };
            e.prototype.clickItem = function () {
                s.default.open(r.UIID.UIReward, {data: this.rewardData, id: this.id, kind: this.kind});
            };
            e.prototype.reward2Data = function () {
                var t = this.rewardData,
                    e = GameDataValue.getShopKey(t.cost_item),
                    o = t.cost_num || 0;
                e >= o && o > 0 ? GameDataValue.setShopKey(t.cost_item, o - 1) : t.diamond_num;
                EVUIEffView.emit(EVUIEffView.clickShopItem, this.kind, this.id);
            };
            n([u(cc.Sprite)], e.prototype, "coin", void 0);
            n([u(cc.Node)], e.prototype, "btnNode", void 0);
            n([u(cc.Label)], e.prototype, "costLab", void 0);
            n([u(p.default)], e.prototype, "timeShopItem", void 0);
            return n([d], e);
        })(cc.Component));
o.default = h;
